<?php

/**
 * This is the model class for table "prefix_comment_online".
 *
 * The followings are the available columns in table 'prefix_comment_online':
 * @property string $comment_online_id
 * @property string $target_id
 * @property string $target_type
 * @property integer $target_parent_id
 * @property string $comment_id
 * @property Comment $comment
 */
class CommentOnline extends LsActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return CommentOnline the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return Config::Get('db.table.comment_online');
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('comment_id', 'required'),
			array('target_parent_id', 'numerical', 'integerOnly'=>true),
			array('target_id, comment_id', 'length', 'max'=>11),
			array('target_type', 'length', 'max'=>5),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('comment_online_id, target_id, target_type, target_parent_id, comment_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'comment' => array(self::BELONGS_TO, 'Comment', 'comment_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'comment_online_id' => 'Comment Online',
			'target_id' => 'Target',
			'target_type' => 'Target Type',
			'target_parent_id' => 'Target Parent',
			'comment_id' => 'Comment',
		);
	}
}